package edu.mse.camel.client.posterboard.ui.editpart.policy;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;

import edu.mse.camel.client.posterboard.posterboard.Posterboard;
import edu.mse.camel.client.posterboard.ui.commands.PBDiagramDeleteCommand;
import edu.mse.camel.client.posterboard.ui.editpart.IPosterBoardDiagramEditpart;

public class PBDiagramComponentEditPolicy extends ComponentEditPolicy {
	
	protected Command createDeleteCommand(GroupRequest deleteRequest) {
		Object parent = getHost().getParent().getModel();
		IPosterBoardDiagramEditpart host = (IPosterBoardDiagramEditpart) getHost();
		if (parent instanceof Posterboard) {
			return new PBDiagramDeleteCommand((Posterboard) parent, host.getPbDiagram());
		}
		return super.createDeleteCommand(deleteRequest);
	}
	
}
